﻿using System;
using System.Data;
using System.Linq;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {
        public void UBTAB05BTP()
        {
            try
            {
                DataTable dtrSoruce = dsSource.Tables["ABPOS"];
                string BARCODE = "", SRC = "";
                int x = dtrSoruce.Rows.Count;
                int i = 0;
                int rows = 5;

                foreach (DataRow dw in dtrSoruce.Rows)
                {
                    int abtp = int.Parse(dw["ABPTP"].ToString());
                    int TPSTART = int.Parse(dw["TPSTART"].ToString());
                    
                    for (int pi = TPSTART; pi <= abtp; pi++)
                    {  
                        SRC = dw["ABPAUFKRS"].ToString() + dw["ABPAUFLFD"].ToString() +Helpers.Helper.Right("0000"+pi.ToString(),4);
                        if (SRC == "") continue;
                        BARCODE = "*" + SRC + "*";
                        exAgent.SetCellValue(i * rows + 1, 1, BARCODE);
                        SRC = dw["ABPART"].ToString().Trim();
                        exAgent.SetCellValue(i * rows + 3, 1, Helpers.Helper.Convert8859P1ToGB2312(SRC));
                        //SRC = dw["FIN"].ToString().Trim() + "/" + dw["DES"].ToString().Trim();
                        //exAgent.SetCellValue(i * rows + 4, 1, Helpers.Helper.Convert8859P1ToGB2312(SRC));
                        i = i + 1;
                        exAgent.RangeCopy(1, rows, i * rows + 1, i * rows + rows);  
                    }
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
    }
}